In [2]:
%pylab inline
In [3]:
import pandas
import matplotlib.pyplot as plt
import numpy as np
import sunpy
import matplotlib
import seaborn as sns
from scipy import stats
In [4]:
sns.set_color_palette("deep", desat=.6)
In [5]:
import heroespy
First load the data, this loads all of the data from all the solar observations, these files can be recreated using the script inside notebooks called
In [6]:
date_format = "%Y-%m-%d %H:%M:%S.%f"
In [77]:
file = "/Users/schriste/Dropbox/Developer/HEROES/HEROES-Telescope/SAS1_pointing_data.csv"
In [78]:
data = pandas.read_csv(file, parse_dates=True, index_col = 0)
In [79]:
data
Out[79]:
In [9]:
data.describe()
Out[9]:
The large max values suggest that we have some bad data which we should get rid of
In [10]:
5*data['offset x'].std()
Out[10]:
In [11]:
con1 = np.abs(data['offset x']) < 5*data['offset x'].std()
con2 = np.abs(data['offset y']) < 5*data['offset y'].std()
index = (con1 * con2) == 1
In [12]:
np.sum(index)
Out[12]:
Number of bad values
In [13]:
np.sum(index == False)
Out[13]:
In [14]:
clean_data = data[index]
clean_data.describe()
Out[14]:
In [16]:
col = 'ctl az'
fig = plt.figure(figsize=(8,6), dpi=100)
clean_data[col].plot()
Out[16]:
The CTL az should not be changing as a function of time! It should be in sky coordinates and following the Sun! Something is wrong here.
A close up view of the time series
In [17]:
fig = plt.figure(figsize=(8,6), dpi=100)
clean_data[col][10000:12000].plot()
Out[17]:
In [81]:
from scipy import fftpack
In [80]:
clean_data.resample('10s')
y = clean_data
Out[80]:
In [18]:
col = 'ctl el'
fig = plt.figure(figsize=(8,6), dpi=100)
clean_data[col].plot()
Out[18]:
In [19]:
col = 'ctl az'
fig = plt.figure(figsize=(8,6), dpi=100)
ax1 = sns.distplot(clean_data[col], bins=100, kde=False, fit=stats.norm, legend = True)
ax1.legend()
ax1.set_title('HEROES/SAS PYAS-F $x_{mean}$ = ' + str(clean_data[col].mean()) + ' $\sigma_x$ = ' + str(clean_data[col].std())[0:6])
ax1.set_xlabel(col + ' [arcsec]')
plt.show()
In [20]:
col = 'ctl el'
fig = plt.figure(figsize=(8,6), dpi=100)
ax1 = sns.distplot(clean_data[col], bins=100, kde=False, fit=stats.norm, legend = True)
ax1.legend()
ax1.set_title('HEROES/SAS PYAS-F $x_{mean}$ = ' + str(clean_data[col].mean()) + ' $\sigma_x$ = ' + str(clean_data[col].std())[0:6])
ax1.set_xlabel(col + ' [arcsec]')
plt.show()
In [21]:
col = 'offset x'
fig = plt.figure(figsize=(8,6), dpi=100)
ax1 = sns.distplot(clean_data[col], bins=100, kde=False, fit=stats.norm, legend = True)
ax1.legend()
ax1.set_title('HEROES/SAS PYAS-F $x_{mean}$ = ' + str(clean_data[col].mean()) + ' $\sigma_x$ = ' + str(clean_data[col].std())[0:6])
ax1.set_xlabel(col + ' [arcsec]')
plt.show()
The mean should likely be zero as this is the offset. It's not clear to me where a dc offset would come from.
In [22]:
fig = plt.figure(figsize=(8,6), dpi=100)
clean_data[col].plot()
Out[22]:
In [ ]:
fig = plt.figure(figsize=(8,6), dpi=100)
clean_data[col][10000:12000].plot()
In [23]:
col = 'offset y'
fig = plt.figure(figsize=(8,6), dpi=100)
ax1 = sns.distplot(clean_data[col], bins=100, kde=False, fit=stats.norm, legend = True)
ax1.legend()
ax1.set_title('HEROES/SAS PYAS-F $x_{mean}$ = ' + str(clean_data[col].mean()) + ' $\sigma_x$ = ' + str(clean_data[col].std())[0:6])
ax1.set_xlabel(col + ' [arcsec]')
plt.show()
The norm fit is not great here. Constraining the data may help.
In [24]:
col = 'offset r'
fig = plt.figure(figsize=(8,6), dpi=100)
ax1 = sns.distplot(clean_data[col], bins=100, kde=True, legend = True)
ax1.legend()
ax1.set_title('HEROES/SAS PYAS-F $x_{mean}$ = ' + str(clean_data[col].mean()) + ' $\sigma_x$ = ' + str(clean_data[col].std())[0:6])
ax1.set_xlabel(col + ' [arcsec]')
plt.show()
Now lets plot the pointing accuracy over the entire solar observation as an offset from the target
In [56]:
kde2d = stats.gaussian_kde([clean_data['offset x'].values, clean_data['offset y'].values])
density = kde2d(heatmap)
In [63]:
heatmap, xedges, yedges = np.histogram2d(clean_data['offset x'].values, clean_data['offset y'].values, bins=200, normed = True)
In [73]:
cumsum = np.cumsum(heatmap, axis=0)
In [74]:
plt.figure()
plt.imshow(cumsum)
Out[74]:
In [58]:
extent1 = [yedges[0], yedges[-1], xedges[-1], xedges[0]]
fig, ax = plt.subplots(figsize=(8,6), dpi=100)
#cax = plt.hist2d(clean_data['offset x'].values, clean_data['offset y'].values, bins=100, cmap = "PuRd", normed=True)
#ax.contour(kde2d, extent = extent)
cax = plt.imshow(heatmap, extent = extent1, origin = 'upper', hold = 'on', cmap="PuRd")
cax.set_interpolation('bilinear')
cnt = plt.contour(heatmap, extent = extent1, origin = 'upper')
ax.set_title('HEROES/SAS PYAS-F')
ax.set_xlabel('Heliospheric Offset X [arcsec]')
ax.set_ylabel('Heliospheric Offset Y [arcsec]')
ax.set_xlim(-100,100)
ax.set_ylim(-100,100)
plt.colorbar()
plt.show()
In [59]:
from sunpy.map import Map
file = '/Users/schriste/Downloads/aia.lev1.193A_2013-09-21T16_00_06.84Z.image_lev1.fits'
map = Map(file)
fov = 9*60
target = np.array([-794., 102])
corner = target - fov/2.0
xrange = corner[0] + np.array([0, fov])
yrange = corner[1] + np.array([0, fov])
smap = map.submap(xrange, yrange)
heatmap, xedges, yedges = np.histogram2d(clean_data['pointing y'].values, clean_data['pointing x'].values, bins=200)
extent = [yedges[0], yedges[-1], xedges[-1], xedges[0]]
In [60]:
heatmap.max(), heatmap.min()
Out[60]:
In [61]:
masked_data = np.ma.masked_where(heatmap < 10, heatmap)
In [62]:
fig, ax = plt.subplots(figsize=(15,10), dpi=100)
cax = smap.plot()
smap.draw_limb()
ax.plot(target[0], target[1], "w+")
ax.imshow(masked_data, extent = extent, alpha = 0.5, cmap = plt.get_cmap('jet_r'))
ax.set_xbound(xrange[0], xrange[1])
ax.set_ybound(yrange[0], yrange[1])
plt.show()
In [ ]: